package com.lzh.exer;

import java.util.Scanner;

public class ArrayDemo1 {
	
	public static void main(String[] args) {
		//1.使用Scanner,读取学生个数
		Scanner sc = new Scanner(System.in);
		System.out.print("请输入学生人数");
		int StudentNum = sc.nextInt();
		
		//2.创建数组，存储学生成绩，动态初始化
		System.out.println("请输入"+StudentNum+"个成绩：");
		//3.给数组中的元素赋值
		int[] StudentArray = new int[StudentNum];
		int maxSorce = 0;
		for(int i=0;i<StudentArray.length;i++) {
			StudentArray[i] = sc.nextInt();
			if(StudentArray[i]>maxSorce) {
				maxSorce = StudentArray[i];
			}
		}
		//4.获取数组中的元素的最大值：最高分
//		for(int j=1;j<StudentArray.length;j++) {
//			if(StudentArray[j]>maxSorce) {
//				maxSorce = StudentArray[j];
//			}
//		}
		System.out.println("最高分数是："+maxSorce);
		//5.根据每个学生成绩与最高分的差值，得到每个学生的等级，并输出等级和成绩
		char level;
		for(int k =0;k<StudentArray.length;k++) {
			if(maxSorce - StudentArray[k]<=10) {
				level = 'A';
			}else if(maxSorce - StudentArray[k]<=20) {
				level = 'B';
			}else if(maxSorce - StudentArray[k]<=30){
				level = 'C';
			}else {
				level = 'D';
			}
			System.out.println("student "+k+" score is "+StudentArray[k]+" grade is "+level);
		}
	}
}
